package prototype.example;

/**
 * @author Chen Guang
 * @date 2019/4/8 0008 下午 14:27
 */
public class Test {
    public static void main(String[] args) throws Exception{
        Resume resume = new Resume("都是辣鸡");
        resume.setPersonalInfo(18,"男");
        resume.setSalary(10000);
        //设置公司
        Company company = new Company();
        company.setName("MONTNETS");
        company.setAddress("高新中四道");
        company.setScope("middle");

        resume.setWorkExperience("2017-08  2019-04", company);

        System.out.println(resume);

        System.out.println("clone:");

        Resume resume1 = (Resume) resume.clone();

        //设置公司
        //Company newCompany = new Company();
        //newCompany.setName("中国平安");
        //newCompany.setAddress("福田金融中心");
        //newCompany.setScope("BIG");
        //resume1.setCompany(newCompany);

        //由于Object自带的object方法是浅复制，因此改动引用类型的值，原型对象的内容也会被改变
        //实现深复制的话则让Company也实现clone方法
        resume1.getCompany().setScope("BIG");

        resume1.setSalary(16000);
        System.out.println(resume1);
        System.out.println(resume);
    }
}
